<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
            All Film On Site
            <small class="label label-success">You can add a new Film and control your films</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">request</li>
    </ol>
</section>
<section class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title"> Show List Videos</h3>
                    
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <div class="mailbox-controls">
                            <!-- Check all button -->
                            <button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
                            <div class="btn-group">
                                <button class="btn btn-default btn-sm"><i class="fa fa-trash-o"></i></button>
                                <button class="btn btn-default btn-sm"><i class="fa fa-reply"></i></button>
                                <button class="btn btn-default btn-sm"><i class="fa fa-share"></i></button>
                            </div>
                            <!-- /.btn-group -->
                            <button class="btn btn-default btn-sm"><i class="fa fa-refresh"></i></button>
                            <button class="btn btn-success btn-flat"><i class="fa fa-plus"></i> Add Film</button>
                    </div>
                    <table id="example1" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Title</th>
                                <th>Content</th>
                                <th>KeyWork</th>
                                <th>Tool</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>Internet Explorer 4.0</td>
                                <td>Win 95+</td>
                                <td> 4</td>
                                <td>
                                    <button type="" class="btn btn-default btn-sm"><i class="fa fa-edit"></i>Edit</button> 
                                    <button type="" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i>Delete</button>
                                    <button class="btn bg-orange btn-sm">Unslider</button>
                                </td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>Rendering engine</th>
                                <th>Browser</th>
                                <th>Platform(s)</th>
                                <th>Engine version</th>
                                <th>CSS grade</th>
                            </tr>
                        </tfoot>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
    </div>
</section>
<script>
    jQuery(document).ready(function($) {
        $('input[type="checkbox"]').iCheck({
          checkboxClass: 'icheckbox_flat-blue',
          radioClass: 'iradio_flat-blue'
        });
        
        $(".checkbox-toggle").click(function () {
          var clicks = $(this).data('clicks');
          if (clicks) {
            //Uncheck all checkboxes
            $("input[type='checkbox']").iCheck("uncheck");
            $(".fa", this).removeClass("fa-check-square-o").addClass('fa-square-o');
          } else {
            //Check all checkboxes
            $("input[type='checkbox']").iCheck("check");
            $(".fa", this).removeClass("fa-square-o").addClass('fa-check-square-o');
          }          
          $(this).data("clicks", !clicks);
        });
    });
    
    function Add(){
        var url = '<?php echo base_url("admin/film/add");?>';
        $(".content").mask("<?php echo 'Loading...'; ?>");
        window.location.href = url;
    }

    function Ep_Multi(id){
        var url = '<?php echo base_url("admin/episode/multi");?>'+'/'+id;
        $(".content").mask("<?php echo 'Loading...'; ?>");
        window.location.href = url;
    }

    function Film_Edit(id){
        $(".content").mask("<?php echo 'Loading...'; ?>");
        var url = '<?php echo base_url("admin/film/edit");?>'+'/'+id;
        window.location.href = url;
    }

    function change_status(id,status){
        $(".content").mask("<?php echo 'Loading...'; ?>");
        var base_url = '<?php echo base_url("admin/film/change_status");?>'; 
        $.post(base_url,{action:true,id:id,status:status}, function(results) {
            $(".content").unmask();
            var html = '';
            if(status == 'publish'){
                html += "<a href=\"javascript:change_status("+id+",'unpublish');\" class=\"label label-success\">Published</a>";
            }else{
                html += "<a href=\"javascript:change_status("+id+",'publish');\" class=\"label label-danger\">Unpublished</a>"; 
            }
            $("#change-"+id).html(html);
        });
    }

    function change_slider(id,status){
        $(".content").mask("<?php echo 'Loading...'; ?>");
        var base_url = '<?php echo base_url("admin/film/change_slider");?>'; 
        $.post(base_url,{action:true,sid:id,status:status}, function(results) {
            $(".content").unmask();
            var html = '';
            if(status == 'publish'){
                html += "<a href=\"javascript:change_slider("+id+",'unpublish');\" class=\"label label-success\">Published</a>";
            }else{
                html += "<a href=\"javascript:change_slider("+id+",'publish');\" class=\"label label-danger\">Unpublished</a>"; 
            }
            $("#slider-"+id).html(html);
        });
    }

    function Ep_List(id){
        $(".content").mask("<?php echo 'Loading...'; ?>");
        var url = '<?php echo base_url("admin/episode/index");?>'+'/'+id;
        window.location.href = url;
    }

    function Ep_Add(id){
        $(".content").mask("<?php echo 'Loading...'; ?>");
        var url = '<?php echo base_url("admin/episode/add");?>'+'/'+id;
        window.location.href = url;
    }

    function Film_Delete(id){
        $.sModal({
            image:'<?php echo base_url("assets/admin");?>/img/confirm.png',
            content:'<?php echo "Do you want to delete this film ?"; ?>',
            animate:'fadeDown',
            buttons:[
                        {
                            text:'<i class="fa fa-times-circle"></i> Delete',
                            addClass:'btn-danger',
                            click:function(){
                                $(".content").mask("<?php echo 'Loading...'; ?>");
                                var url = '<?php echo base_url("admin/film/delete");?>'+'/'+id;
                                window.location.href = url;
                            }
                        },
                        {
                            text:'Cancel',
                            click:function(id,data){
                                $.sModal('close',id);
                            }
                        },
                    ]
        });
    }
    
    function bulk_action(type){
        if (type != undefined){
            $.sModal({
                image:'<?php echo base_url("assets/admin");?>/img/confirm.png',
                content:'<?php echo "Do you want to delete this member ?"; ?>',
                animate:'fadeDown',
                buttons:[
                         {
                             text:'<i class="fa fa-times-circle"></i> OK',
                             addClass:'btn-danger',
                             click:function(m_id,data){
                                    $(".content").mask("<?php echo 'Loading...'; ?>");
                                    $.post($('#frm-bulk-action').attr('action')+'/'+type,$('#frm-bulk-action').serialize(),function(obj){
                                        $('.content').load(obj.url,function(){
                                           $('.content input[type="checkbox"]').iCheck({checkboxClass: 'icheckbox_minimal'});
                                           $('.content input[type="radio"]').iCheck({radioClass: 'iradio_minimal'});
                                           $(".content").unmask();
                                           if (obj.error == 0){
                                             switch(obj.action){
                                               case 'delete':
                                                 $.notification({type:"success",img:"",width:"400",content:"<i class='fa fa-check fa-2x'></i> <?php echo 'Film is deleted successfully'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                                                 break;
                                               case 'publish':
                                                 $.notification({type:"success",img:"",width:"400",content:"<i class='fa fa-check fa-2x'></i> <?php echo 'Film is activated successfully'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                                               break;
                                               case 'unpublish':
                                                 $.notification({type:"success",img:"",width:"400",content:"<i class='fa fa-check fa-2x'></i> <?php echo 'Film is deactivated successfully'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                                               break;
                                           }
                                           }else{
                                                $.notification({type:"error",img:"",width:"400",content:"<i class='fa fa-times-circle fa-2x'></i> <?php echo 'There is an error, please check again!'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                                           }
                                        });
                                      $.sModal('close',m_id);
                                    },'json');
                             }
                         },
                         {
                             text:'Cancel',
                             click:function(id,data){
                                 $.sModal('close',id);
                             }
                         },
                     ]
            });
        }
    }

</script>